package com.lengjing.project.service.impl;

import com.lengjing.project.common.MsgReturn;
import com.lengjing.project.mapper.UserMapper;
import com.lengjing.project.model.User;
import com.lengjing.project.service.UserService;
import com.lengjing.project.util.PropertyCodeMsgUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description :
 * @Author : ChenYao
 * @Version : 1.0
 * @Create : Date Time: 2018/6/25 14:04
 * @Update : Date Time: 2018/6/25 14:04
 * @see :
 */
@Service("userService")
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public MsgReturn getUserList(int page,int count) {
        Map<String, Object> map = new HashMap<String, Object>(16);
        map.put("begin", (page - 1) * count);
        map.put("count", count);
        List<User> userList = userMapper.getAllUser(map);
        if (userList == null || userList.size() < 1) {
            return MsgReturn.ERROR_NODATA;
        }
        return new MsgReturn(MsgReturn.SUCCESS, PropertyCodeMsgUtil.getPropertyValue(MsgReturn.SUCCESS), userList);
    }

    @Override
    public User login(User user) {

        return userMapper.login(user);
    }
}
